package com.cloudsigns.factorymanager2.engineering.activity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.cloudsigns.factorymanager2.R;
import com.cloudsigns.factorymanager2.cusenum.CommonEnum;
import com.cloudsigns.factorymanager2.engineering.IView.IDeleteEgnineeringOrderView;
import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringConstructOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.IView.IEngineeringInstallOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.IView.IPatrolOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.IView.IPublicationOrderDetailView;
import com.cloudsigns.factorymanager2.engineering.IView.ISendOrderForSuperView;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringConstructOrderBean;
import com.cloudsigns.factorymanager2.engineering.bean.EngineeringInstallationOrderBean;
import com.cloudsigns.factorymanager2.engineering.bean.OrderParentBean;
import com.cloudsigns.factorymanager2.engineering.bean.PatrolOrderBean;
import com.cloudsigns.factorymanager2.engineering.bean.PublicationOrderDetailBean;
import com.cloudsigns.factorymanager2.engineering.bean.UserInfoBean;
import com.cloudsigns.factorymanager2.engineering.presenter.DeleteEngineeringOrderPresenter;
import com.cloudsigns.factorymanager2.engineering.presenter.EngineeringConstructOrderDetailPresenter;
import com.cloudsigns.factorymanager2.engineering.presenter.EngineeringInstallOrderDetailPresenter;
import com.cloudsigns.factorymanager2.engineering.presenter.PatrolOrderDetailPresenter;
import com.cloudsigns.factorymanager2.engineering.presenter.PublicationOrderDetailPresenter;
import com.cloudsigns.factorymanager2.engineering.presenter.SendOrderForSuperPresenter;
import com.cloudsigns.factorymanager2.project.activity.ViewSurveyOrderDetailForProjectActivity;
import com.cloudsigns.factorymanager2.project.bean.SurVeyOrderBean;
import com.cloudsigns.factorymanager2.project.iview.ISurveyOrderDetailView;
import com.cloudsigns.factorymanager2.project.presenter.SurveyOrderDetailPresenter;
import com.cloudsigns.factorymanager2.project.utils.ConstantUtil;

/**
 * 项目部工单派发
 * Created by tony on 2018/3/27.
 */

public class SendOrderForSuperActivity extends Activity implements View.OnClickListener, ISendOrderForSuperView, IDeleteEgnineeringOrderView, IEngineeringInstallOrderDetailView
        , IEngineeringConstructOrderDetailView, IPublicationOrderDetailView, IPatrolOrderDetailView,ISurveyOrderDetailView {
    private View rl_back;
    private RelativeLayout rl_right;
    private TextView tv_title;
    private View ll_edit_information;
    private TextView edt_dispatching_way_colon,edt_company_name, edt_receive_people_colon;
    private RelativeLayout rl_company_name;
    //edt_receive_people_colon edt_external_dispatch_company, edt_dispath_order_time_colon, edt_receiving_company_colon, edt_docking_people_colon, edt_reception_time_colon;
//    private View rl_external_dispatch_company, rl_dispath_order_time_colon, rl_receive_people_colon, rl_reception_time_colon;
    private TextView btn_dispatch_order, btn_delete_engineering_order;
    private TextView tv_project_name, tv_engineering_name;
    private View ll_dispatch_content;
    private View rl_engineering_name;
    private ImageView img_edit_dispatch_information;
    private OrderParentBean orderParentBean;
    private boolean isDelete = true, isDispatch;
    //    private String receiveAccountId = "";
    private UserInfoBean userInfoBean;
    private SendOrderForSuperPresenter sendEngineeringOrderPresenter;
    private DeleteEngineeringOrderPresenter deleteEngineeringOrderPresenter;
    private EngineeringInstallOrderDetailPresenter engineeringInstallOrderDetailPresenter;
    private EngineeringInstallationOrderBean engineeringInstallationOrderBean;
    private EngineeringConstructOrderBean engineeringConstructOrderBean;
    private PublicationOrderDetailPresenter publicationOrderDetailPresenter;
    private PublicationOrderDetailBean publicationOrderBean;
    private PatrolOrderDetailPresenter patrolOrderDetailPresenter;
    private PatrolOrderBean patrolOrderBean;
    private SurveyOrderDetailPresenter surveyOrderDetailPresenter;
    private SurVeyOrderBean surVeyOrderBean;
    private EngineeringConstructOrderDetailPresenter engineeringConstructOrderDetailPresenter;
    private String TAG = SendOrderForSuperActivity.class.getSimpleName();


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉标题栏
        // 沉浸式状态栏
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            Window window = getWindow();
            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
                    );
            window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN

                    | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
            window.setStatusBarColor(Color.TRANSPARENT);

        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        }
        setContentView(R.layout.layout_send_engineering_order);

        sendEngineeringOrderPresenter = new SendOrderForSuperPresenter(this);
        deleteEngineeringOrderPresenter = new DeleteEngineeringOrderPresenter(this);
        engineeringInstallOrderDetailPresenter = new EngineeringInstallOrderDetailPresenter(this);
        publicationOrderDetailPresenter = new PublicationOrderDetailPresenter(this);
        patrolOrderDetailPresenter = new PatrolOrderDetailPresenter(this);
        engineeringConstructOrderDetailPresenter = new EngineeringConstructOrderDetailPresenter(this);
        surveyOrderDetailPresenter = new SurveyOrderDetailPresenter(this);

        init();
        initData();

    }

    private void init() {
        rl_back = findViewById(R.id.rl_back);
        rl_right=findViewById(R.id.rl_right);
        tv_title = findViewById(R.id.tv_title);
        ll_edit_information = findViewById(R.id.ll_edit_information);
        edt_dispatching_way_colon = findViewById(R.id.edt_dispatching_way_colon);
        rl_company_name=findViewById(R.id.rl_company_name);
        edt_company_name=findViewById(R.id.edt_company_name);
//        edt_external_dispatch_company = findViewById(R.id.edt_external_dispatch_company);
//        edt_dispath_order_time_colon = findViewById(R.id.edt_dispath_order_time_colon);
//        edt_receiving_company_colon = findViewById(R.id.edt_receiving_company_colon);
//        edt_docking_people_colon = findViewById(R.id.edt_docking_people_colon);
        btn_dispatch_order = findViewById(R.id.btn_dispatch_order);
        btn_delete_engineering_order = findViewById(R.id.btn_delete_engineering_order);
        tv_project_name = findViewById(R.id.tv_project_name);
        tv_engineering_name = findViewById(R.id.tv_engineering_name);
        ll_dispatch_content = findViewById(R.id.ll_dispatch_content);
//        rl_external_dispatch_company = findViewById(R.id.rl_external_dispatch_company);
//        rl_dispath_order_time_colon = findViewById(R.id.rl_dispath_order_time_colon);
//        rl_receive_people_colon = findViewById(R.id.rl_receive_people_colon);
//        rl_reception_time_colon = findViewById(R.id.rl_reception_time_colon);
        edt_receive_people_colon = findViewById(R.id.edt_receive_people_colon);
//        edt_reception_time_colon = findViewById(R.id.edt_reception_time_colon);
        rl_engineering_name = findViewById(R.id.rl_engineering_name);
        img_edit_dispatch_information = findViewById(R.id.img_edit_dispatch_information);

        rl_right.setVisibility(View.GONE);
        rl_back.setOnClickListener(this);
        ll_edit_information.setOnClickListener(this);
        btn_dispatch_order.setOnClickListener(this);
        btn_delete_engineering_order.setOnClickListener(this);
        rl_engineering_name.setOnClickListener(this);
        img_edit_dispatch_information.setOnClickListener(this);

        if (TextUtils.isEmpty(edt_company_name.getText().toString())){
            rl_company_name.setVisibility(View.GONE);
        }else{
            rl_company_name.setVisibility(View.VISIBLE);
        }


        Intent intent = getIntent();
        if (null != intent) {
            orderParentBean = (OrderParentBean) intent.getSerializableExtra(ConstantUtil.KEY_1);

        }

        if (null != orderParentBean) {
            if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.CREATED) {
                ll_dispatch_content.setVisibility(View.GONE);
                img_edit_dispatch_information.setVisibility(View.VISIBLE);
            } else if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.EDITED) {
                img_edit_dispatch_information.setVisibility(View.VISIBLE);
            } else if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.SEND) {
                ll_dispatch_content.setVisibility(View.VISIBLE);
                img_edit_dispatch_information.setVisibility(View.VISIBLE);

            } else if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.RECEIVED) {
                ll_dispatch_content.setVisibility(View.VISIBLE);
//                rl_receive_people_colon.setVisibility(View.VISIBLE);
//                rl_reception_time_colon.setVisibility(View.VISIBLE);
                img_edit_dispatch_information.setVisibility(View.GONE);

            } else if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.RETURNED) {
                ll_dispatch_content.setVisibility(View.VISIBLE);
                img_edit_dispatch_information.setVisibility(View.GONE);

            } else if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.COMPLETED) {
                ll_dispatch_content.setVisibility(View.VISIBLE);
                img_edit_dispatch_information.setVisibility(View.GONE);

            } else if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.CONSTRUCT) {
                ll_dispatch_content.setVisibility(View.VISIBLE);
                img_edit_dispatch_information.setVisibility(View.GONE);

            } else if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.PAUSE) {
                ll_dispatch_content.setVisibility(View.VISIBLE);
                img_edit_dispatch_information.setVisibility(View.GONE);

            } else {
//                rl_receive_people_colon.setVisibility(View.GONE);
//                rl_reception_time_colon.setVisibility(View.GONE);
                img_edit_dispatch_information.setVisibility(View.GONE);

                isDispatch = false;

            }

            setClickable();
        }

    }

    private void initData() {
        if (null != orderParentBean) {
            if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.INSTALL) {
                tv_title.setText(getResources().getText(R.string.engineering_installation));
                tv_project_name.setText(orderParentBean.getProjectName());
                tv_engineering_name.setText("/" + orderParentBean.getEngineeringName());
//                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(orderParentBean.getSendOrderTime()));


                engineeringInstallOrderDetailPresenter.getEngineeringInstallOrderDetail();

            } else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.BATCH_INSTALL) {
                tv_title.setText(getResources().getText(R.string.batch_installation));
                tv_project_name.setText(orderParentBean.getProjectName());
                tv_engineering_name.setText("/" + orderParentBean.getEngineeringName());
//                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(orderParentBean.getSendOrderTime()));
            } else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.CONSTRUCT) {
                tv_title.setText(getResources().getText(R.string.engineering_construct));
                tv_project_name.setText(orderParentBean.getProjectName());
                tv_engineering_name.setText("/" + orderParentBean.getEngineeringName());
//                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(orderParentBean.getSendOrderTime()));

                engineeringConstructOrderDetailPresenter.getEngineeringConstructOrderDetail();

            } else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.MAINTAIN) {
                tv_title.setText(getResources().getText(R.string.maintenance));
                tv_project_name.setText(orderParentBean.getProjectName());
                tv_engineering_name.setText("/" + orderParentBean.getEngineeringName());
//                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(orderParentBean.getSendOrderTime()));
            } else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.PUBLICATION) {
                tv_title.setText(getResources().getString(R.string.publication));
                tv_project_name.setText(orderParentBean.getProjectName());
                tv_engineering_name.setText("/" + orderParentBean.getEngineeringName());
//                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(orderParentBean.getSendOrderTime()));

                publicationOrderDetailPresenter.getPublicationOrderDetail();
            } else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.PATROL) {
                tv_title.setText("巡查工单");
                tv_project_name.setText(orderParentBean.getProjectName());

//                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(orderParentBean.getSendOrderTime()));

                patrolOrderDetailPresenter.getPatrolOrderDetail();
            }else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.SURVEY) {
                tv_title.setText(getResources().getString(R.string.engineering_patro));
                tv_project_name.setText(orderParentBean.getProjectName());

//                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(orderParentBean.getSendOrderTime()));

                surveyOrderDetailPresenter.surveyOrderDetail();
            }
        }
    }

    private void initPublicationOrderDetail() {
        if (null != publicationOrderBean) {
            edt_dispatching_way_colon.setText("内派");

            edt_receive_people_colon.setText(publicationOrderBean.getReceiveAccountName() + ":" + publicationOrderBean.getReceiveAccountId());

        }
    }

    private void initPatrolOrderDetail() {
        if (null != patrolOrderBean) {
            edt_dispatching_way_colon.setText("内派");

            edt_receive_people_colon.setText(patrolOrderBean.getReceiveAccountName());
        }
    }

    private void initSurVeyOrderDetail() {
        if (null != surVeyOrderBean) {
            edt_dispatching_way_colon.setText("内派");

            edt_receive_people_colon.setText(surVeyOrderBean.getReceiveAccountName());
        }
    }

    private void initEngineeringInstallOrderDispatchInfo() {
        if (null != engineeringInstallationOrderBean) {

            edt_dispatching_way_colon.setText("内派");
            edt_receive_people_colon.setText(engineeringInstallationOrderBean.getReceiveAccountName() + ":" + engineeringInstallationOrderBean.getReceiveAccountId());
////            edt_docking_people_colon.setText(engineeringInstallationOrderBean.getReceiveAccountName() + ":" + engineeringInstallationOrderBean.getReceiveAccountId());
//            if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.RECEIVED) {
//                edt_receive_people_colon.setText(engineeringInstallationOrderBean.getReceiveAccountId());
////                edt_reception_time_colon.setText(DateUtil.getYyyy_Mm_Dd(engineeringInstallationOrderBean.getReceiveOrderTime()));
//            } else if (orderParentBean.getStatus() != CommonEnum.EngineeringOrderStatus.CREATED) {
////                edt_external_dispatch_company.setText(engineeringInstallationOrderBean.getCompanyName() + ":" + engineeringInstallationOrderBean.getCompanyId());
////                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(engineeringInstallationOrderBean.getSendOrderTime()));
////                edt_external_dispatch_company.setVisibility(View.VISIBLE);
////                edt_dispath_order_time_colon.setVisibility(View.VISIBLE);
//            }
        }
    }

    private void initEngineeringConstructOrderDispatchInfo() {
        if (null != engineeringConstructOrderBean) {
            edt_dispatching_way_colon.setText("内派");
            edt_receive_people_colon.setText(engineeringConstructOrderBean.getReceiveAccountName());
////            edt_docking_people_colon.setText(engineeringConstructOrderBean.getReceiveAccountName() + ":" + engineeringConstructOrderBean.getReceiveAccountId());
//
//            if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.RECEIVED) {
//                edt_receive_people_colon.setText(engineeringConstructOrderBean.getReceiveAccountId());
////                edt_reception_time_colon.setText(DateUtil.getYyyy_Mm_Dd(engineeringConstructOrderBean.getReceiveOrderTime()));
//            } else if (orderParentBean.getStatus() != CommonEnum.EngineeringOrderStatus.CREATED) {
////                edt_external_dispatch_company.setText(engineeringConstructOrderBean.getCompanyName() + ":" + engineeringConstructOrderBean.getCompanyId());
////                edt_dispath_order_time_colon.setText(DateUtil.getYyyy_Mm_Dd(engineeringConstructOrderBean.getSendOrderTime()));
////                edt_external_dispatch_company.setVisibility(View.VISIBLE);
////                edt_dispath_order_time_colon.setVisibility(View.VISIBLE);
//            }

            String contentId=engineeringConstructOrderBean.getId();
            String receiveAccountId=engineeringConstructOrderBean.getReceiveAccountId();

            Log.e(TAG,"--------contentId1="+contentId);
            Log.e(TAG,"--------receiveAccountId1="+receiveAccountId);
        }
    }

    private void showDetail() {
        Intent mIntent;
        if (null != orderParentBean) {
            // 工程安装
            if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.INSTALL) {
                // mIntent = new Intent(SendOrderForSuperActivity.this, ViewEngineeringInstallOrderDetailActivity.class);
                mIntent = new Intent(SendOrderForSuperActivity.this, ViewEngineeringInstallOrderDetailActivity1.class);
                mIntent.putExtra(ConstantUtil.KEY_1, TAG);
                mIntent.putExtra(ConstantUtil.KEY_2, engineeringInstallationOrderBean);
                startActivity(mIntent);
            }
            // 批量安装
            else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.BATCH_INSTALL) {

            }
            // 工程施工
            else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.CONSTRUCT) {
               // mIntent = new Intent(SendOrderForSuperActivity.this, ViewEngineeringConstructOrderDetailActivity.class);
                mIntent = new Intent(SendOrderForSuperActivity.this, ViewEngineeringConstructOrderDetailActivity1.class);
                mIntent.putExtra(ConstantUtil.KEY_1, TAG);
                mIntent.putExtra(ConstantUtil.KEY_2, engineeringConstructOrderBean);
                startActivity(mIntent);

            }
            // 维修
            else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.MAINTAIN) {

            }
            // 广告上刊
            else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.PUBLICATION) {
               // mIntent = new Intent(SendOrderForSuperActivity.this, PublicationOrderDetailActivity.class);
                mIntent = new Intent(SendOrderForSuperActivity.this, PublicationOrderDetailActivity1.class);
                mIntent.putExtra(ConstantUtil.KEY_1, TAG);
                mIntent.putExtra(ConstantUtil.KEY_2, publicationOrderBean);
//                mIntent.putExtra(ConstantUtil.KEY_2, orderParentBean);
                startActivity(mIntent);

//                mIntent = new Intent(SendOrderForSuperActivity.this, PublicationOrderDetailActivity.class);
//                mIntent.putExtra(ConstantUtil.KEY_1, TAG);
//                mIntent.putExtra(ConstantUtil.KEY_2, publicationOrderBean);
//                startActivity(mIntent);
            }
            // 巡查
            else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.PATROL) {
               // mIntent = new Intent(SendOrderForSuperActivity.this, PatrolOrderDetailActivity.class);
                mIntent = new Intent(SendOrderForSuperActivity.this, PatrolOrderDetailActivity1.class);
                mIntent.putExtra(ConstantUtil.KEY_1, TAG);
                mIntent.putExtra(ConstantUtil.KEY_2, patrolOrderBean);
                startActivity(mIntent);
            }
            // 现场勘查
            else if (orderParentBean.getCategory() == CommonEnum.EngineeringORderCategory.SURVEY) {
                mIntent = new Intent(SendOrderForSuperActivity.this, ViewSurveyOrderDetailForProjectActivity.class);
                mIntent.putExtra(ConstantUtil.KEY_1, TAG);
                mIntent.putExtra(ConstantUtil.KEY_2, patrolOrderBean);
                startActivity(mIntent);
            }

        }
    }

    private void setClickable() {
        if (isDispatch)
            btn_dispatch_order.setBackgroundColor(getResources().getColor(R.color.rgb_00B050));
        else
            btn_dispatch_order.setBackgroundColor(getResources().getColor(R.color.rgb_D9D9D9));

        if (isDelete)
            btn_delete_engineering_order.setBackgroundColor(getResources().getColor(R.color.rgb_C00000));
        else
            btn_delete_engineering_order.setBackgroundColor(getResources().getColor(R.color.rgb_D9D9D9));

    }

    private void dispatchEngineeringOrder() {
        sendEngineeringOrderPresenter.sendEngineeringOrder();
    }

    @Override
    public void onClick(View view) {
        TextView tv;
        Intent mIntent;
        switch (view.getId()) {
            case R.id.rl_back:
                finish();
                break;
            case R.id.img_edit_dispatch_information:
                if (null != orderParentBean) {

                    if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.CREATED || orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.EDITED || orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.SEND) {
                        mIntent = new Intent(SendOrderForSuperActivity.this, EditDispatchInformationForEngineeringInstallationOrderActivity.class);
                        mIntent.putExtra(ConstantUtil.KEY_1, CommonEnum.ROLECATEGORY.MANAGER);
                        startActivityForResult(mIntent, ConstantUtil.START_ACTIVITY_KEY_1);
                    }
                }


                break;

                // 删除工单
            case R.id.btn_delete_engineering_order:
                if (isDelete) {

                    isDelete = false;
                    setClickable();
                    deleteEngineeringOrderPresenter.deleteEngineeringOrder();

                }
                break;
            case R.id.btn_dispatch_order:
                if (isDispatch) {
                    isDispatch = false;
                    setClickable();
                    dispatchEngineeringOrder();
                }


                break;
            case R.id.rl_engineering_name: //查看详情
                showDetail();
                break;

        }
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
            case ConstantUtil.START_ACTIVITY_KEY_1:
                if (data != null) {
                    String dispatch_way = data.getStringExtra("dispatch_way");
                    edt_dispatching_way_colon.setText(dispatch_way);
                    if (dispatch_way.equals("内派")) {
                        userInfoBean = (UserInfoBean) data.getSerializableExtra(ConstantUtil.KEY_1);
                        if (null != userInfoBean)
                            edt_receive_people_colon.setText(userInfoBean.getName() + ":" + userInfoBean.getId());
//                            edt_docking_people_colon.setText(userInfoBean.getName() + ":" + userInfoBean.getId());
                    } else if (dispatch_way.equals("外派")) {
//                        edt_docking_people_colon.setText(data.getStringExtra(ConstantUtil.KEY_1));
//                        edt_receiving_company_colon.setText(data.getStringExtra(ConstantUtil.KEY_2));
                    }

                    ll_dispatch_content.setVisibility(View.VISIBLE);
                    isDelete = true;
                    isDispatch = true;
                    setClickable();
                }

                break;

        }
        super.onActivityResult(requestCode, resultCode, data);
    }

    @Override
    public String getId() {
        return orderParentBean.getId();
    }


    @Override
    public String getReceiveAccountId() {
        if (null != userInfoBean)
            return userInfoBean.getId();
        return "";
    }

    @Override
    public CommonEnum.EngineeringORderCategory getEngineeringDeptOrderCategoryEnum() {

        if (null != orderParentBean)
            return orderParentBean.getCategory();

        return null;
    }


    @Override
    public String getItemId() {
        return null;
    }


    @Override
    public void surveyOrderDetailSuccessed(SurVeyOrderBean surVeyOrderBean) {
        this.surVeyOrderBean= surVeyOrderBean;
        initSurVeyOrderDetail();
    }

    @Override
    public void surveyOrderDetailFailed(String desc) {

    }

    @Override
    public long getFeedbackDate() {
        return 0;
    }

    @Override
    public String getOrderId() {
        if (null != orderParentBean)
            return orderParentBean.getId();
        return null;
    }

    @Override
    public void getPatrolOrderDetailSuccessed(PatrolOrderBean patrolOrderBean) {
        this.patrolOrderBean = patrolOrderBean;
        initPatrolOrderDetail();
    }

    @Override
    public void gPatrolOrderDetailFailed(String desc) {

    }

    @Override
    public void getPublicationOrderDetailSuccessed(PublicationOrderDetailBean publicationOrderBean) {
        this.publicationOrderBean = publicationOrderBean;
        initPublicationOrderDetail();
    }

    @Override
    public void gePublicationOrderDetailFailed(String desc) {

    }

    @Override
    public void diapatchSuccess() {
        setResult(6, new Intent());
        Toast.makeText(this, "派发成功", Toast.LENGTH_SHORT).show();
        finish();
    }

    @Override
    public void sendEngineeringOrderFailed(String desc) {
        Toast.makeText(this, desc, Toast.LENGTH_SHORT).show();
        isDelete = true;
        isDispatch = true;
        setClickable();
    }

    @Override
    public void deleteSunccessed() {

        setResult(6, new Intent());
        Toast.makeText(this, "删除成功", Toast.LENGTH_SHORT).show();
        finish();
    }


    @Override
    public void deleteEngineeringOrderFailed(String desc) {
        Toast.makeText(this, desc, Toast.LENGTH_SHORT).show();
        if (orderParentBean.getStatus() == CommonEnum.EngineeringOrderStatus.CREATED) {
            isDelete = true;
            isDispatch = true;
        } else {
            isDispatch = false;
            isDelete = true;

        }
        setClickable();
    }

    @Override
    public void getEngineeringConstructOrderDetailSuccessed(EngineeringConstructOrderBean engineeringConstructOrderBean) {
        this.engineeringConstructOrderBean = engineeringConstructOrderBean;
        initEngineeringConstructOrderDispatchInfo();
    }

    @Override
    public void getEngineeringConstructOrderDetailFailed(String desc) {
        Toast.makeText(this, desc, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void getEngineeringInstallOrderDetailSuccessed(EngineeringInstallationOrderBean engineeringInstallationOrderBean) {
        this.engineeringInstallationOrderBean = engineeringInstallationOrderBean;
        initEngineeringInstallOrderDispatchInfo();
    }


    @Override
    public void getEngineeringInstallOrderDetailFailed(String desc) {
        Toast.makeText(this, desc, Toast.LENGTH_SHORT).show();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }
}
